<template>
  <div class="user-container">
    <el-card>
      <template #header>
        <div class="header">
          <el-button type="primary" @click="handleAdd">新增用户</el-button>
        </div>
      </template>
      
      <el-table :data="userList" v-loading="loading">
        <el-table-column prop="username" label="用户名" />
        <el-table-column prop="name" label="姓名" />
        <el-table-column prop="phone" label="手机号" />
        <el-table-column prop="email" label="邮箱" />
        <el-table-column label="操作">
          <template #default="{ row }">
            <el-button type="primary" link @click="handleEdit(row)">编辑</el-button>
            <el-button type="danger" link @click="handleDelete(row)">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
    </el-card>
  </div>
</template>

<script setup lang="ts">
import { ref, onMounted } from 'vue'
import { getUserList, deleteUser } from '@/api/user'
import type { User } from '@/types/api/user'

const loading = ref(false)
const userList = ref<User[]>([])

onMounted(async () => {
  await loadUsers()
})

const loadUsers = async () => {
  loading.value = true
  try {
    const { data } = await getUserList({ pageNum: 1, pageSize: 10 })
    userList.value = data.list
  } finally {
    loading.value = false
  }
}

// TODO: 实现新增、编辑、删除功能
</script> 